package cn.sciento.transfer.infra.repository.impl;

import io.choerodon.mybatis.pagehelper.PageHelper;
import io.choerodon.mybatis.pagehelper.domain.PageRequest;
import java.util.List;
import cn.sciento.mybatis.base.impl.BaseRepositoryImpl;
import cn.sciento.transfer.domain.entity.DbMigrationLog;
import cn.sciento.transfer.domain.repository.DbMigrationLogRepository;
import cn.sciento.transfer.infra.mapper.DbMigrationLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DbMigrationLogRepositoryImpl extends BaseRepositoryImpl<DbMigrationLog> implements DbMigrationLogRepository {
  @Autowired
  DbMigrationLogMapper dbMigrationLogMapper;
  
  public List<DbMigrationLog> pageQueryByOption(DbMigrationLog dbMigrationLog, PageRequest pageRequest) {
    if (pageRequest == null)
      return this.dbMigrationLogMapper.selectByOption(dbMigrationLog); 
    return PageHelper.doPageAndSort(pageRequest, () -> this.dbMigrationLogMapper.selectByOption(dbMigrationLog));
  }
}
